<template>
  <div class="app-container">
    <div class="app-title">
      <span>单位信息审核</span>
    </div>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-col
          :span="1"
        >
          <i
            :class="[treeShow ? 'el-icon-s-fold treeI': 'el-icon-s-unfold treeI']"
            @click="toggerTree"
          />
        </el-col>
        <div class="tap-fillet">
          <el-radio-group
            v-model="activeName"
            style="margin-left:4rem; width:700px; height:15px; margin-top:-57px"
          >
            <el-radio-button
              label="1"
              name="all"
            >未审核
            </el-radio-button>
            <el-radio-button
              label="2"
              name="submit"
            >已审核
            </el-radio-button>
          </el-radio-group>
        </div>
      </el-col>
      <div class="filter-container">
        <div>
          <el-col
            style="text-align:right; margin-top: -8px;"
            :span="16"
          >
            <el-button
              size="small"
              class="filter-item"
              style="margin-left: 10px;"
              type="primary"
              @click="handleView"
            >
              预览
            </el-button>
            <el-button
              v-if="activeName=='1'"
              size="small"
              font-size="14px"
              class="filter-item"
              style="margin-left: 10px;"
              type="primary"
              :loading="verifyLoading"
              @click="handleAudit"
            >
              审核
            </el-button>
            <el-button
              v-if="activeName=='1'"
              size="small"
              class="filter-item"
              type="primary"
              :loading="returnLoading"
              @click="handleReturn"
            >
              退回
            </el-button>
            <!-- <el-button
              v-if="activeName=='1'"
              size="small"
              class="filter-item"
              type="primary"
              @click="handleRevokeReturn"
            >
              撤销退回
            </el-button> -->
            <el-button
              v-if="activeName=='2'"
              size="small"
              class="filter-item"
              style="margin-left: 10px;"
              type="primary"
              :loading="revokeLoading"
              @click="handleRevokeAudit"
            >
              撤销审核
            </el-button>
            <el-button
              size="small"
              class="filter-item"
              style="margin-left: 10px;"
              type="primary"
              @click="appendixOpen"
            >
              附件管理
            </el-button>
          </el-col>
        </div>
      </div>
    </el-row>
    <div>
      <div style="margin-left:165px; position:absolute; margin-top:-37px">
        <img
          style="width:16px; height:16px;"
          :src="Processedimg"
        >
      </div>
      <div style="margin-left:75px; position:absolute; margin-top:-37px">
        <img
          style="width:16px; height:16px;"
          :src="Untreatedimg"
        >
      </div>
    </div>

    <div
      ref="box"
      class="box"
    >
      <div
        class="left"
        :class="[isActive ? 'wid':'wids']"
      >
        <div
          :class="[treeShow ? 'treeShow' : 'treeNotShow']"
          :style="{'height' : treeHeight + 'px'}"
        >
          <AgencyTree
            class="agencyTree"
            style="margin-top:10px;"
            @handleTreeQuery="handleTreeQuery"
          />
        </div>
      </div>
      <div v-show="Show" class="resize" title="收缩侧边栏" />
      <div
        class="mid"
        :class="[isActive ? 'mids': 'min']"
      >
        <unitInfoAuditChildrenTable
          :key="timer"
          ref="chil"
          :tab-pane="activeName"
          :tree-data="treeData"
          @revokeCallback="revokeCallback()"
        />

      </div>
      <Drag ref="icon" />

    </div>
  </div>
</template>

<script>
import unitInfoAuditChildrenTable from '@/views/unitInformationMaintenance/children/unitInformationAuditChildren'
import AgencyTree from '@/components/tree/agencyTree'
import Drag from '@/components/Drag'

export default {
  name: 'UnitInformationAudit',
  components: { unitInfoAuditChildrenTable, AgencyTree, Drag },
  data() {
    return {
      treeHeight: null,
      treeShow: false,
      timer: '',
      activeName: '1',
      treeData: [],
      noAudit: true,
      isActive: true,
      Show: false,
      verifyLoading: false,
      revokeLoading: false,
      returnLoading: false,
      Untreatedimg: require('@/assets/images/select.png'),
      Processedimg: require('@/assets/images/processed.png')
    }
  },
  watch: {
    activeName(val) {
      this.timer = new Date().getTime()
      if (val === '1') {
        this.Processedimg = require('@/assets/images/processed.png')
        this.Untreatedimg = require('@/assets/images/select.png')
      } else {
        this.Processedimg = require('@/assets/images/blue.png')
        this.Untreatedimg = require('@/assets/images/blueselect.png')
      }
    }
  },
  created() {
  },
  mounted() {
    this.dragController()
    this.getTeHeight()
  },
  beforeMount() {
    window.addEventListener('resize', this.getTeHeight)
  },
  methods: {
    getTeHeight() {
      this.treeHeight = window.innerHeight - 270
    },
    // 拖拽
    dragController() {
      this.$refs.icon.dragControllerDiv()
    },
    // 树方法
    toggerTree() {
      this.treeShow = !this.treeShow
      this.isActive = !this.isActive
      this.Show = !this.Show
    },
    handleView() {
      this.$refs.chil.handleView()
    },
    handleAudit() {
      this.$refs.chil.handleAudit()
    },
    handleRevokeAudit() {
      this.revokeLoading = true
      this.$refs.chil.handleRevokeAudit()
    },
    handleReturn() {
      this.$refs.chil.handleReturn()
    },
    revokeCallback() {
      this.revokeLoading = !this.revokeLoading
    },
    handleRevokeReturn() {
      this.$refs.chil.handleRevokeReturn()
    },
    handleTreeQuery(data) {
      this.treeData = data
      this.$refs.chil.handleTree(data)
    },
    // 打开弹窗
    appendixOpen() {
      this.$refs.chil.appendixOpen()
    }
  }
}
</script>
